#!/bin/sh

cd /opt/wanalytics/scripts/
PWD=`pwd`
SCRIPTS=`dirname $PWD`/scripts

logname=`date   +%Y%m%d`
if [ ! -n "$1" ]; then
    logname=`python -u $SCRIPTS/Yesterday.py`
else
	logname=$1	
fi

datelog=`date   +%Y%m%d%H%M%S`
log="/opt/wanalytics/scripts/log/Split_${logname}_${datelog}.log"

if [ ! -d "/opt/wanalytics/scripts/log/" ]; then
    mkdir -p  /opt/wanalytics/scripts/log/
fi


if [ ! -d "/opt/temp/" ]; then
    mkdir -p  /opt/temp/
fi

cd  /opt/temp/

if [ "$2"x = "nolog"x ]; then
	python -u /opt/wanalytics/scripts/Split.py $*
else
	echo ${log}	
	python -u /opt/wanalytics/scripts/Split.py $*  >> ${log} 2>&1
fi
